const Sequelize = require('sequelize')
const db = require('../db')
const ProviderModel = require('./provider')
//定义地址实体对象模型
const Bill = db.define(
  'Bill',
  {
    id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
    billCode: { type: Sequelize.STRING },
    productName: { type: Sequelize.STRING },
    productDesc: { type: Sequelize.STRING },
    productUnit: { type: Sequelize.STRING },
    productCount: { type: Sequelize.DECIMAL },
    totalPrice: { type: Sequelize.DECIMAL },
    isPayment: { type: Sequelize.BIGINT },
    createdBy: { type: Sequelize.BIGINT },
    createdAt: { type: Sequelize.DATE },
    modifyBy: { type: Sequelize.BIGINT },
    updatedAt: { type: Sequelize.DATE },
    providerId: { type: Sequelize.BIGINT },
  },
  {
    underscored: false,
    tableName: 'smbms_bill',
  }
)
//设置外键关联
Bill.belongsTo(ProviderModel, { foreignKey: 'providerId', constraints: false })
module.exports = Bill
